package cn.com.smartdevices.bracelet.chart.data;

import android.os.AsyncTask;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/* renamed from: cn.com.smartdevices.bracelet.chart.b.a */
public class AsyncChartDataLoader extends cn.com.smartdevices.bracelet.chart.data.ChartDataLoader { // C0747a
    private Executor f3947d;
    protected ArrayList<C0749c> f3948e;

    public AsyncChartDataLoader() {
        this.f3947d = Executors.newSingleThreadExecutor();
        this.f3948e = new ArrayList();
    }

    class C0749c extends AsyncTask<Integer, Void, ItemData> {
        final /* synthetic */ AsyncChartDataLoader f3949a;

        protected C0749c(AsyncChartDataLoader c0747a) {
            this.f3949a = c0747a;
        }

        protected ItemData m8621a(Integer... numArr) {
            ItemData b = this.f3949a.f3944a.loadData(numArr[0].intValue());
            b.f3897g = numArr[0].intValue();
            this.f3949a.f3945b.put(numArr[0].intValue(), b);
            return b;
        }

        protected void m8622a(ItemData c0737e) {
            this.f3949a.f3944a.onDataLoaded(c0737e);
            this.f3949a.f3948e.remove(this);
        }

        protected /* synthetic */ ItemData doInBackground(Integer[] objArr) {
            return m8621a((Integer[]) objArr);
        }

        protected void onCancelled() {
            this.f3949a.f3948e.remove(this);
        }

        @Override
        protected /* synthetic */ void onPostExecute(ItemData obj) {
            m8622a((ItemData) obj);
        }
    }

    public void m8618a(int i) {
        C0749c c0749c = new C0749c(null);
        c0749c.executeOnExecutor(this.f3947d, new Integer[]{Integer.valueOf(i)});
        this.f3948e.add(c0749c);
    }

    public boolean m8619a() {
        if (!this.f3948e.isEmpty()) {
            Iterator it = this.f3948e.iterator();
            while (it.hasNext()) {
                if (((C0749c) it.next()).isCancelled()) {
                    return true;
                }
            }
        }
        return false;
    }

    public void m8620b() {
        if (!this.f3948e.isEmpty()) {
            Iterator it = this.f3948e.iterator();
            while (it.hasNext()) {
                C0749c c0749c = (C0749c) it.next();
                if (!c0749c.isCancelled()) {
                    c0749c.cancel(false);
                }
            }
        }
        this.f3948e.clear();
    }
}
